package com.example.basic.base;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.basic.lifecycle.ActivityLifecycleLogger;
import com.example.basic.status_bar.StatusBar;
import com.example.basicsharedlib.R;

import java.io.FileDescriptor;
import java.io.PrintWriter;

public abstract class BaseActivity extends AppCompatActivity {



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        //设置颜色为透明
        StatusBar statusBar = new StatusBar(BaseActivity.this);
        statusBar.setStatusBarColor(R.color.transparent);

        //无title
//        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //全屏
//        getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
//                WindowManager.LayoutParams. FLAG_FULLSCREEN);

        if (setLayoutXmlid() != 0) {
            setContentView(setLayoutXmlid());
        }
        initOnCreate(savedInstanceState);
        getLifecycle().addObserver(new ActivityLifecycleLogger(this));
    }

    protected abstract void initOnCreate(@Nullable Bundle savedInstanceState);

    protected abstract int setLayoutXmlid();

    public abstract String getTag();

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
    }

    //支持dumpsys命令
    @Override
    public void dump(@NonNull String prefix, @Nullable FileDescriptor fd, @NonNull PrintWriter writer, @Nullable String[] args) {
        writer.println("我是" + getClass().getName());
    }

}
